1. Field of the Invention
The present invention relates to a method and an apparatus for detecting image movement, and more particularly to a method and an apparatus for detecting image movement capable of enhancing displacement and small angle detection.
2. Description of the Related Art
With the advance of computer functions, and development in internet and multi-media technology, image data are transmitted in the digital form, rather than in analog form. In order to meet the modern life style, peripheral apparatus of computers have developed to be slim, precisely controllable, and multi-functional. For example, a conventional mouse uses a ball to control the locations. Though the structure is simple, a mouse must be frequently cleaned to get rid of the accumulated dust, and also the low location resolution is another disadvantage. The recently introduced optical mouse can resolve this issue and precisely control the location and reduce errors.
The traditional optical mouse uses the block match method to determine the displacement of the frame detector. By comparing the acquired sampling window and the reference window based on the mean-squared error method, or a mean absolute difference (MAD) method, the displacement of the frame detector can be obtained.
FIG. 1 is a flowchart showing a conventional block match method to determine the displacement of a frame detector. Referring to FIG. 1, the frame detector first captures a reference frame at the first location in the step S10. In the step S112, the detector moves to a second location to capture another sampling frame. If both the reference frame and the sampling frame are 6×6, then a smaller 2×2 reference window is captured from the reference frame, and the frame is divided into 9 non-overlapping frame windows. Then, a window having the same gray level as that of the frame window in the sampling frame is sequentially sought according to the block match method. The relative functions of the frame window and the sampling frame are calculated in the step S13. In the step S14, the displacement and the moving vector between the windows having the smallest functions are calculated. In the step S16, it is determined whether the frame window has reached the margin of the frame. If the frame window has reached the margin of the frame, the original reference frame is replaced by the sampling frame as a new reference frame in the step S18. In fact, the frame detector has several noise sources. In addition to the variation of the semiconductor process, the noises from the power, and the signal noises, the frame detector is also affected by temperature and brightness of the outside environment. Accordingly, only the window having the gray level most similar to that of the previous frame can be found. Detecting errors are unavoidable.
In the traditional technology, due to the restrictions of the frame detector size and the frame speed, the moving speed of the frame detector is limited. If the frame captured by the frame detector is M×M, and the frame window is N×N, the pixel dimension of the frame detector is PN×PN, and the frame speed is FN frame/sec. In the example that the frame window is located at the center of the acquired frame array, the displacement ranges allowed in the horizontal and the vertical directions are ±(M−N)/2, and the maximum moving speeds allowed in the in the horizontal and the vertical directions are PN×[±(M−N)/2]×FN. When the moving speed of the frame detector is higher than the limit allowed for the hardware, the window having a gray level similar to that of the frame window cannot be captured by the block match method. This will result in incorrect determination in the block match method, and the displacement of the frame detector cannot be correctly calculated.
Accordingly, a method for detecting displacement of a frame detector is provided in the US Patent Application Publication 2003/0081129, entitled “METHOD FOR DETECTING MOVEMENT OF IMAGE SENSORS”, filed by Lin et al. In this patent publication, the frame detector captures a specific part of the reference frame at the first location. The frame detector then moves to the second location to capture a sampling frame. By comparing the reference frame and the sampling frame, the frame with the same specific part of the reference frame is obtained, and the displacement of the frame detector is determined. Based on the moving direction of the detector, the location of a new reference frame captured by the frame detector at the third location is determined so as to calculate the displacement of the frame detector. This patent dynamically adjusts the location of the reference window of the next reference frame to enhance the maximum displacement. Though increasing the maximum displacement, this method cannot enhance the moving angle detection.
The U.S. Pat. No. 5,729,008 provides a method of detecting frame displacement. This method uses a quadric to form the correlation surface model, and the point of the minimum value to calculate the integer part of the displacement. Based on the correlation value of the point and the surrounding points, the minor displacement in decimal is calculated by the interpolation method. When the correlation value is calculated, the difference at each point must be measured, and hardware is required to calculate the displacement in decimal. As a result, a complex and great calculation is unavoidable.
Accordingly, for keeping the hardware structure simple and reducing the calculation, the conventional method to detect the image movement still leaves room for improvement.